package com.medic.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.medic.entity.Assitant;
import com.medic.entity.Doctor;
import com.medic.entity.Pharmacist;
import com.medic.entity.User;
import com.medic.entity.Weichat;
import com.medic.mapper.interf.WeichatMapper;
import com.medic.service.interf.WeichatServiceInterface;

@Service("weichatService")
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // 注明需要回滚
public class WeichatServiceImpl implements WeichatServiceInterface {

	@Resource
	private WeichatMapper weichatMapper;
		
	
	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED) 
	public List<Weichat> getRoleByOpenID(String openid) throws Exception {
		
		return weichatMapper.selectRoleByOpenid(openid);
		
		
	}

	@Transactional(propagation = Propagation.NOT_SUPPORTED) 
	@Override
	public Doctor getDoctorByWeichatid(int weichatid) throws Exception {
		return weichatMapper.selectDoctorByWeichatid(weichatid);
	}
	
	@Transactional(propagation = Propagation.NOT_SUPPORTED) 
	@Override
	public User getUserByWeichatid(int weichatid) throws Exception {
		return weichatMapper.selectUserByWeichatid(weichatid);
	}
	
	@Transactional(propagation = Propagation.NOT_SUPPORTED) 
	@Override
	public Pharmacist getPharmaicstByWeichatid(int weichatid) throws Exception {
		return weichatMapper.selectPharmaicstByWeichatid(weichatid);
	}
	
	@Transactional(propagation = Propagation.NOT_SUPPORTED) 
	@Override
	public Assitant getAssitantByWeichatid(int weichatid) throws Exception {
		return weichatMapper.selectAssitantByWeichatid(weichatid);
	}

	@Override
	public boolean delete(Weichat object) throws Exception {
		return false;
	}

	@Override
	public boolean save(Weichat object) throws Exception {
		weichatMapper.save(object);
		return true;
	}

	@Override
	public boolean update(Weichat object) throws Exception {
		return false;
	}

}
